//////////////////////////////////////////////////////////////////////////
/// Copyright (c) 2011, Sidorenko 'PC' Alexander                       ///
/// mailto: sidorenko /*dot*/ alexander (at) gmail [dot] com           ///
/// This file is a part of the Radiating Gas Dynamics project          ///
//////////////////////////////////////////////////////////////////////////

#ifndef Problem_INCLUDED
#define Problem_INCLUDED

class ProblemListener
{
public:

	virtual void onStepCompleated(gdScalar time, gdScalar totalTime, unsigned int numTimesteps) = 0;

};

class CColorBar;

class Problem
{
public:

	enum Type
	{
		SODS_SHOCK_TUBE,
		BRICK_2D,
		SOD_2D,
		UNKNOWN
	};

	Problem(Type type) : m_type(type) {}
	virtual ~Problem() {}

	virtual void setListener(ProblemListener* pListener) = 0;

	inline Type getType() const { return m_type; }

	// Will start solving process and write entire solution to the file
	// specified. WILL NOT READ THIS FILE WHEN FINISHED! See openFile
	virtual void solve(gdScalar time, const std::string& fileName) = 0;
	virtual gdScalar getTime(unsigned int timeStep) const = 0;
	virtual unsigned int getNumSteps() const = 0;

	// Will open solution file and start background thread to read it.
	virtual bool openFile(const std::string& fileName) = 0;

	virtual unsigned int getNumPlotTypes() const = 0;
	virtual std::string getPlotTypeName(unsigned int id) const = 0;
	virtual bool plotSolution(CDC& dc, const CRect& dstRect,
							  const CColorBar& clr,
							  unsigned int timeStep, unsigned int plotType) = 0;

	static Problem* readProblem(std::string fileName);

protected:

	virtual void solveRadiation() {}

	Type m_type;

};

#endif // Problem_INCLUDED